import { Breadcrumb } from 'antd';
import { withRouter, Link } from 'react-router-dom';
import { breadcrumbList } from '@/utils';
import { flattenRoute } from '../../router';
import './index.less';

function Breadcrumbs(props) {
  const {
    location: { pathname },
  } = props;
  const list = breadcrumbList(pathname).map((item) => {
    return flattenRoute.find((items) => items.path == item);
  });
  console.log('list', list);
  return (
    <Breadcrumb separator=">" className="breadcrumb">
      {list.map((item) => {
        return (
          <Breadcrumb.Item key={item.path}>
            <Link to={item.redirect || item.path}>{item.title}</Link>
          </Breadcrumb.Item>
        );
      })}
    </Breadcrumb>
  );
}
export default withRouter(Breadcrumbs);
